package com.zhuojy.equity.mall.admin.service.car;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.po.car.TCarEtcConsumePO;
import com.zhuojy.equity.mall.admin.common.pojo.ResultEntity;
import com.zhuojy.equity.mall.admin.dal.mapper.car.TCarEtcConsumeMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author xrz
 * @version 1.0
 * @description:TODO
 * @date 2024/4/11 20:44
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TCarEtcConsumeService extends ServiceImpl<TCarEtcConsumeMapper, TCarEtcConsumePO>  {
    public ResultEntity findconsumerPagination(TCarEtcConsumePO tCarMaintainPO, Integer pageSize, Integer pageNum) {
        Page<TCarEtcConsumePO> page = new Page<>(pageNum, pageSize);
        IPage<TCarEtcConsumePO> tCarMaintainPOIPage = this.baseMapper.findconsumerPagination(tCarMaintainPO, page);
        return ResultEntity.OK(tCarMaintainPOIPage);
    }

    public ResultEntity addconsume(TCarEtcConsumePO tCarEtcConsumePO) {
        this.baseMapper.insert(tCarEtcConsumePO);
        return ResultEntity.OK("添加成功");
    }

    public ResultEntity upconsume(TCarEtcConsumePO tCarEtcConsumePO) {
        this.baseMapper.updateById(tCarEtcConsumePO);
        return ResultEntity.OK("操作成功");
    }

    public ResultEntity echoconsume(Integer id) {
        TCarEtcConsumePO tCarEtcConsumePO = this.baseMapper.selectById(id);
        return ResultEntity.OK(tCarEtcConsumePO);
    }

    public ResultEntity delconsume(Integer id) {
        this.baseMapper.deleteById(id);
        return ResultEntity.OK("操作成功");
    }
}
